export default {
	install(Vue, options) {
		//  Vue.prototype.url= "http://www.baidu.com/"   //可以自定义变量
		Vue.prototype.setCookie = function(name, value) {
			var Minutes = 10;
			var exp = new Date();
			exp.setTime(exp.getTime(+Minutes * 60 * 1000));
			document.cookie = name + "=" + escape(value) + ";expries=" + exp.toGMTString() + ";path=/";
		}

		Vue.prototype.getCookie = function(name) {
			var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
			if(arr = document.cookie.match(reg)) {
				return unescape(arr[2]);
			} else {
				return null;
			}
		}

		Vue.prototype.delCookie = function(name) {
			var exp = new Date();
			exp.setTime(exp.getTime() - 1);
			var cval = getCookie(name);
			if(cval != null) {
				document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString() + ";path=/";
			}
		}

		//时间戳转换方法    date:时间戳数字
		Vue.prototype.formatDate = function(date) {
			var date = new Date(date);
			var YY = date.getFullYear() + '-';
			var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
			var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
			var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
			var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
			var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
			return YY + MM + DD + " " + hh + mm + ss;
		}

	}
}